/*
 * Copyright (C) Beijing Decision Credit Technologies, Ltd
 *
 * ProjectName:WIKKaShen
 * PackageName:com.woaika.kashen.common
 * FileName:FragPagerAdapter.java
 * 
 */
package com.qdaily.ui.data;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.qdaily.ui.QDBaseFragment;

/**
 * Description: Fragment适配器
 * Author: chencheng
 * Date: 2014-11-12上午11:34:30
 * Version:1.0
 */
public class FragPagerAdapter extends FragmentPagerAdapter {
    private QDBaseFragment[] fragments = null;

    public FragPagerAdapter(FragmentManager fm, QDBaseFragment[] fragments) {
        super( fm );
        if (fragments != null && fragments.length > 0) {
            this.fragments = fragments;
        } else {
            try {
                throw new Exception( "this FragPagerAdapter Count must have > 0" );
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public Fragment getItem(int position) {
        return fragments[ position ];
    }

    @Override
    public int getCount() {
        return fragments.length;
    }
}
